<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
	<ui:composition template="/templates/padraoJSF.xhtml">
	
		<ui:define name="barraTitulo">Digita&ccedil;&atilde;o de Faltas</ui:define>
		<ui:define name="conteudo"> 
			<h:form id="form">
				<p:growl id="messages"/>
				<fieldset>
					<p:tabView>
						<p:tab title="Cadastro">
							<h:panelGrid columns="2" columnClasses="alinhaDir" >
								<h:column >
								</h:column>
								<h:column >
									<h:outputText value="Os campos com asterisco (*) s&atilde;o de preenchimento obrigat&oacute;rio." styleClass="campoObrigatorio" />
								</h:column>
								<h:column >
									<h:outputText value="Centro" styleClass="select" />
								</h:column>
								<h:column >
									<h:selectOneMenu value="#{controleFalta.faculdade}" >
									  	<f:selectItem itemLabel="selecione" itemValue="#{controleFalta.faculdadeSelecione}"/>
					                    <f:selectItems value="#{controleFalta.faculdades}" var="faculdade" itemLabel="#{faculdade.descricao}" itemValue="#{faculdade}"/>
					                    <p:ajax listener="#{controleFalta.filtraCursos}" update="id_cursos id_turmas id_disciplinas" />
					                    <f:converter converterId="converteFaculdade"/>
									</h:selectOneMenu>
									<h:outputText value="(*)" styleClass="campoObrigatorio" />
								</h:column>								

								<h:column >
									<h:outputText value="Curso:" styleClass="select" />
								</h:column>
								<h:column >
									<h:selectOneMenu value="#{controleFalta.curso}" id="id_cursos" >  
									  	<f:selectItem itemLabel="selecione" itemValue="#{controleFalta.cursoSelecione}"/>
					                    <f:selectItems value="#{controleFalta.cursos}" var="curso" itemLabel="#{curso.descricao}" itemValue="#{curso}"/>
					                    <f:converter converterId="converteCurso"/>
					                    <p:ajax listener="#{controleFalta.filtraTurmas}" update="id_turmas id_disciplinas" />
									</h:selectOneMenu>
									<h:outputText value="(*)" styleClass="campoObrigatorio" />
								</h:column>								
								
								<h:column >
									<h:outputText value="Turma:" styleClass="select" />
								</h:column>
								<h:column >
									<h:selectOneMenu value="#{controleFalta.turma}" id="id_turmas">  
									 	<f:selectItem itemLabel="selecione" itemValue="#{controleFalta.turmaSelecione}"/>
					                    <f:selectItems value="#{controleFalta.turmas}" var="turma" itemLabel="#{turma.descricao}" itemValue="#{turma}"/>
					                    <p:ajax listener="#{controleFalta.filtraDisciplinas}" update="id_disciplinas" />
					                    <f:converter converterId="converteTurma"/>
									</h:selectOneMenu>
									<h:outputText value="(*)" styleClass="campoObrigatorio" />
								</h:column>								

								<h:column >
									<h:outputText value="Disciplina:" styleClass="select" />
								</h:column>
								<h:column >
									<h:selectOneMenu value="#{controleFalta.disciplina}" id="id_disciplinas" >  
									 	<f:selectItem itemLabel="selecione" itemValue="#{controleFalta.disciplinaSelecione}"/>
					                    <f:selectItems value="#{controleFalta.disciplinas}" var="disciplina" itemLabel="#{disciplina.descricao}" itemValue="#{disciplina}"/>
					                    <f:converter converterId="converteDisciplina"/>
									</h:selectOneMenu>
									<h:outputText value="(*)" styleClass="campoObrigatorio" />
								</h:column>								

								<h:column >
								</h:column>
								<h:column >
									<h:commandLink action="#{controleFalta.filtraHistoricos}">
										<h:graphicImage url="/images/botoes/btnPesquisar.png" class="alinhaEsq" />
									</h:commandLink>
								</h:column>
								
							</h:panelGrid>
							
							
							<table>
								<tr class="titulo">
									<td class="alinhaMeio width50">N&ordm;</td>
									<td class="auto">Nome</td>
									
									<c:if test="#{controleFalta.tipoCurso.codigoTipoCurso == 1}" >
										<c:choose >
											<c:when test="#{controleFalta.semestre == 1}" >
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[0]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[1]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[2]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[3]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[4]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[5]}"/></td>
											</c:when>
											<c:when test="#{controleFalta.semestre == 2}" >
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[6]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[7]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[8]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[9]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[10]}"/></td>
												<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[11]}"/></td>
											</c:when>
										</c:choose>
									</c:if>
									<c:if test="#{controleFalta.tipoCurso.codigoTipoCurso == 2}" >
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[0]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[1]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[2]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[3]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[4]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[5]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[6]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[7]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[8]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[9]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[10]}"/></td>
										<td class="width10 alinhaMeio"><h:outputText value="#{controleFalta.meses[11]}"/></td>
									</c:if>

									<td class="auto">Total de Faltas</td>
								</tr>

								<c:forEach var="historico" items="#{controleFalta.historicos}" >

									<c:if test="#{corTabela != 'corUm'}" var="controleCor">
										<c:set var="corTabela" value="corUm"></c:set>
									</c:if>
									<c:if test="#{corTabela != 'corDois' and controleCor == false}">
										<c:set var="corTabela" value="corDois"></c:set>
									</c:if>																			
	
									<tr class="#{corTabela}">
										<td class="alinhaMeio">
											<h:outputText value="#{historico.numeroCaderneta}"/>
										</td>
										<td> 
											<h:outputText value="#{historico.aluno.pessoa.nome}"/> 
										</td>
										<c:if test="#{controleFalta.curso.tipoCurso.codigoTipoCurso == 1}" >
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[0].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[1].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[2].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[3].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[4].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[5].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
										</c:if>
										<c:if test="#{controleFalta.tipoCurso.codigoTipoCurso == 2}" >
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[0].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[1].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[2].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[3].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[4].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[5].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[6].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[7].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[8].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[9].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[10].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
											<td class="alinhaMeio">
												<h:selectOneMenu value="#{historico.faltas[11].valor}">  
								                    <f:selectItems value="#{controleFalta.valorFaltas}"/>
												</h:selectOneMenu>										
											</td>
										</c:if>										
										<td class="alinhaMeio">
											<h:outputText value="#{historico.totalFaltas}"/>
										</td>
									</tr>
									
								</c:forEach>
							</table>
							
							
						</p:tab>
					</p:tabView>
					
					
				</fieldset>
				
				
				
				
				<h:commandLink action="#{controleFalta.criar}">
					<h:graphicImage url="/images/botoes/btnLimpar.png" class="btnAcoes" />
				</h:commandLink>
				<h:commandLink action="#{controleFalta.gravar}" styleClass="alinhaDir">
					<h:graphicImage url="/images/botoes/btnGravar.png" class="btnAcoes"/>
				</h:commandLink>	
			</h:form>
		</ui:define>
	</ui:composition>
</html>